package com.ruoyi.controller;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.service.FinanceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 财务报表接口
 * @Author:zzm
 * @Date: 2024/8/29 15:26
 */
@RestController
@RequestMapping("/amac/finance")
public class FinanceController extends BaseController {

    @Autowired
    private FinanceService financeService;

    /**
     * 测试导入两个excel接口
     * @param response
     * @param updateSupport
     * @throws IOException
     */
    @PostMapping("/twoToOne")
    public void twoToOne(HttpServletResponse response, MultipartFile operationsFile, MultipartFile detailsFile, boolean updateSupport) throws IOException {
         financeService.twoToOne(response,operationsFile,detailsFile,updateSupport);
    }

//    @PostMapping("/twoToOne1")
//    public void test( HttpServletResponse response,MultipartFile operationsFile,MultipartFile detailsFile, boolean updateSupport) throws IOException {
//        financeService.test(response,operationsFile,detailsFile,updateSupport);
//    }

    /**
     * 客户成本模板导出
     * @param response
     * @throws Exception
     */
    @PostMapping("/costExport")
    public void costExport(HttpServletResponse response) throws Exception {
        financeService.costExport(response);
    }

    @PostMapping("/cost")
        public void cost( HttpServletResponse response,MultipartFile costFile,MultipartFile detailsFile, boolean updateSupport) throws IOException {
        financeService.cost(response,costFile,detailsFile,updateSupport);

    }

    @PostMapping("/oldLongCost")
    public void oldLongCost( HttpServletResponse response,MultipartFile costFile,MultipartFile detailsFile, boolean updateSupport) throws Exception {
        financeService.oldLongCost(response,costFile,detailsFile,updateSupport);

    }

    @PostMapping("/longCost")
    public void longCost( HttpServletResponse response,MultipartFile costFile,MultipartFile detailsFile, boolean updateSupport) throws Exception {
        financeService.longCost(response,costFile,detailsFile,updateSupport);

    }
    @PostMapping("/longCostBusy")
    public void longCostBusy( HttpServletResponse response,MultipartFile costFile,MultipartFile detailsFile, boolean updateSupport) throws Exception {
        financeService.longCostBusy(response,costFile,detailsFile,updateSupport);

    }
    /**
     * 导出模板
     */
    @PostMapping("/exportTemplate")
    public void handleExport(HttpServletResponse response){
        financeService.handleExport(response);
    }

    @PostMapping("/oldSurroundCost")
    public void oldSurroundCost( HttpServletResponse response,MultipartFile costFile,MultipartFile detailsFile, boolean updateSupport) throws Exception {
        financeService.oldSurroundCost(response,costFile,detailsFile,updateSupport);
    }

    @PostMapping("/surroundCost")
    public void surroundCost( HttpServletResponse response,MultipartFile costFile,MultipartFile detailsFile, boolean updateSupport) throws Exception {
        financeService.surroundCost(response,costFile,detailsFile,updateSupport);
    }
    @PostMapping("/surroundCostBusy")
    public void surroundCostBusy( HttpServletResponse response,MultipartFile costFile,MultipartFile detailsFile, boolean updateSupport) throws Exception {
        financeService.surroundCostBusy(response,costFile,detailsFile,updateSupport);
    }

    /**
     * 分区计费重成本模板导出
     * @param response
     * @throws Exception
     */
    @PostMapping("/partitionWeightExport")
    public void partitionWeightExport(HttpServletResponse response) throws Exception {
        financeService.partitionWeightExport(response);
    }

    /**
     * 拖柜成本核算
     * @param response
     * @param costFile
     * @param detailsFile
     * @param updateSupport
     * @throws IOException
     */
    @PostMapping("/draggingCabinet")
    public void draggingCabinet( HttpServletResponse response,MultipartFile costFile,MultipartFile detailsFile, boolean updateSupport) throws IOException {
        financeService.draggingCabinet(response,costFile,detailsFile,updateSupport);
    }
    /**
     * 拖柜成本导出模板
     */
    @PostMapping("/draggingCabinetExportTemplate")
    public void draggingCabinetExportTemplate(HttpServletResponse response){
        financeService.draggingCabinetExportTemplate(response);
    }

}
